<template>
  <Card v-bind="$attrs" >
    <template #title>
      <Icon icon="ant-design:schedule-outlined" class="m-1 pr-1" />
      <span>延期中项目</span>
    </template>
    <template #extra>
      <a-button type="link" size="small" @click="jump">查看更多 ></a-button>
    </template>
    <!-- :rowClassName="getRowClassName" -->
    <!-- <div style="height:530px; overflow-y: auto;"> -->
      <BasicTable @register="registerTable" >
        <template #projectno="{ record }">
          <a @click="handleDetailsForm(record)">
            {{ record.projectno }}
          </a>
        </template>


        <template #firstColumn="{ record }">
          <div :style="{color: record.warning?'red':'',fontWeight:record.warning?'bold':'' }"> {{ record.projectname }}</div>
        </template>
      </BasicTable>
    <!-- </div> -->
  </Card>
</template>
<script lang="ts" setup>
  import { Card, List } from 'ant-design-vue';
  import { messageItems } from './data';
  import { Icon } from '/@/components/Icon';
  import { BasicTable, BasicColumn, useTable } from '/@/components/Table';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { pmDelayListIndexData } from '/@/api/process/delay/pmDelay';
  import { router } from '/@/router';

  const { t } = useI18n('process.delay.pmDelay');
  const ListItem = List.Item;
  const ListItemMeta = List.Item.Meta;

  const tableColumns: BasicColumn[] = [
  {
      title: t('项目编码'),
      dataIndex: 'projectno',
      width: 120,
      align: 'left',
      slot: 'projectno',
    },
    {
      title: t('项目名称'),
      dataIndex: 'projectname',
      width: 130,
      align: 'left',
      slot: 'firstColumn',
    },
    // {
    //   title: t('开始日期'),
    //   dataIndex: 'starttime',
    //   width: 100,
    //   align: 'center',
    // },
    {
      title: t('结束日期'),
      dataIndex: 'endtime',
      width: 100,
      align: 'center',
    },
    {
      title: t('剩余天数'),
      dataIndex: 'syDays',
      width: 80,
      align: 'center',
      // slot: 'syDays',
      // fixed:'right'
    },
  
  ];

  const [registerTable, { reload, getForm, getSelectRows }] = useTable({
    api: pmDelayListIndexData,
    beforeFetch: (params) => {
      params.pageSize = 10
      return params;
    },
    columns: tableColumns,
    //actionColumn: actionColumn,
    showTableSetting: false,
    useSearchForm: false,
    // isCanResizeParent: true,
    canResize: true,
    minHeight:480,
    // immediate: true,
    showIndexColumn:false,
    pagination:false,
    striped:false,
    bordered:false,
  });

  function jump(){
    router.push({
      // path: '/process/delay/pmDelay/list',
      path: '/process/delay/delaying/list',
      // query: {
      // },
    })
  }
  function getRowClassName(row, index) {
    if (row.warning) {
      return 'rowcolor'; 
    } else {
      return ''; 
    }
  }

  function handleDetailsForm(record: Recordable) {
    router.push({
      path: '/proj/info/pmProjectinformation/detailsForm',
      query: {
        id: record.id,
        code: record.projectno,
        tabTitle: `项目详情(${record.projectno})`,
      },
    });
  }


</script>
<style lang="less">
  .rowcolor{
    td {
      background-color: rgba(255, 0, 0, 0.7) !important;
    }
  }
  .ant-card-body {
      padding: 10px;
      height: 100%;
  }
</style>
